import fetch from './fetch'

export default {
  // 文章列表
  list(params) {
    return fetch.get('/article', params)
  },
  // 文章详情
  detail(params) {
    const id = params.id
    delete params.id
    return fetch.get('/article/' + id, params)
  },
  // 文章详情
  detail(params) {
    const id = params.id
    delete params.id
    return fetch.get('/article/' + id, params)
  },
  // 文章详情
  userDetail(params) {
    const id = params.id
    delete params.id
    return fetch.get('/userInfo/' + id, params)
  },
  // 更新用户
  updateUser(params) {
    const {id} = params;
    delete params.id;
    return fetch.put('/webUser/' + id, params)
  },
  // 更新用户
  updateLove(params) {
    const {id} = params;
    delete params.id;
    return fetch.put('/updateLove/' + id, params)
  },
  // 创建文章
  create(params) {
    return fetch.post('/userArticle', params);
  },
  // 收藏文章
  createLove(params) {
    return fetch.post('/addLove', params);
  },
  // 获取收藏文章
  love(params) {
    const {user_id} = params;
    delete params.user_id;
    return fetch.get('/love/' + user_id, params);
  },

  // 删除文章
  removeLove({article_id}) {
    console.log(article_id);
    return fetch.delete('/removeLove/' + article_id)
  },

  // 删除文章
  userDelArticle({id}) {
    return fetch.delete('/userDelArticle/' + id)
  },
}
